Merge "Normalize `input[type="search"]`"
[lhc/web/wiklou.git] / tests / phpunit / includes / WatchedItemStoreUnitTest.php
index 5f07dbf..78231c2 100644 (file)
@@ -5,7 +5,7 @@
  *
  * @covers WatchedItemStore
  */
-class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
+class WatchedItemStoreUnitTest extends MediaWikiTestCase {
 
        /**
         * @return PHPUnit_Framework_MockObject_MockObject|IDatabase
@@ -82,23 +82,19 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                return $fakeRow;
        }
 
+       private function newWatchedItemStore( LoadBalancer $loadBalancer, HashBagOStuff $cache ) {
+               return new WatchedItemStore(
+                       $loadBalancer,
+                       $cache
+               );
+       }
+
        public function testGetDefaultInstance() {
                $instanceOne = WatchedItemStore::getDefaultInstance();
                $instanceTwo = WatchedItemStore::getDefaultInstance();
                $this->assertSame( $instanceOne, $instanceTwo );
        }
 
-       public function testOverrideDefaultInstance() {
-               $instance = WatchedItemStore::getDefaultInstance();
-               $scopedOverride = $instance->overrideDefaultInstance( null );
-
-               $this->assertNotSame( $instance, WatchedItemStore::getDefaultInstance() );
-
-               unset( $scopedOverride );
-
-               $this->assertSame( $instance, WatchedItemStore::getDefaultInstance() );
-       }
-
        public function testCountWatchedItems() {
                $user = $this->getMockNonAnonUserWithId( 1 );
 
@@ -120,7 +116,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -150,7 +146,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -201,7 +197,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -267,7 +263,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -315,7 +311,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -394,7 +390,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -496,7 +492,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -549,7 +545,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -586,7 +582,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -620,7 +616,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -657,7 +653,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -687,7 +683,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        )
                        ->will( $this->returnValue( new FakeResultWrapper( [] ) ) );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $this->getMockCache()
                );
@@ -745,7 +741,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -791,7 +787,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -871,7 +867,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -903,7 +899,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->method( 'delete' )
                        ->with( '0:Some_Page:1' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -923,7 +919,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )
                        ->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -966,7 +962,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->method( 'delete' )
                        ->with( '1:Some_Page:1' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -990,7 +986,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )
                        ->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1013,7 +1009,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )
                        ->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1047,7 +1043,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                                '0:SomeDbKey:1'
                        );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1081,7 +1077,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1103,7 +1099,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1138,7 +1134,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->method( 'delete' )
                        ->with( '0:SomeDbKey:1' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1173,7 +1169,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->method( 'delete' )
                        ->with( '0:SomeDbKey:1' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1196,7 +1192,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )
                        ->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1240,7 +1236,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                                '0:SomeDbKey:1'
                        );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1274,7 +1270,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        )
                        ->will( $this->returnValue( $cachedItem ) );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1311,7 +1307,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->with( '0:SomeDbKey:1' )
                        ->will( $this->returnValue( false ) );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1334,7 +1330,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1374,7 +1370,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'set' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1424,7 +1420,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        )
                        ->will( $this->returnValue( [] ) );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $mockLoadBalancer,
                        $mockCache
                );
@@ -1437,7 +1433,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
        }
 
        public function testGetWatchedItemsForUser_badSortOptionThrowsException() {
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $this->getMockDb() ),
                        $this->getMockCache()
                );
@@ -1478,7 +1474,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                                '0:SomeDbKey:1'
                        );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1514,7 +1510,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->with( '0:SomeDbKey:1' )
                        ->will( $this->returnValue( false ) );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1537,7 +1533,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1604,7 +1600,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1654,7 +1650,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1715,7 +1711,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1755,7 +1751,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1781,7 +1777,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache = $this->getMockCache();
                $mockCache->expects( $this->never() )->method( $this->anything() );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1805,7 +1801,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1838,7 +1834,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'set' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1883,7 +1879,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->method( 'delete' )
                        ->with( '0:SomeDbKey:1' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1923,7 +1919,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockDb->expects( $this->never() )
                        ->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -1989,7 +1985,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockDb->expects( $this->never() )
                        ->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -2049,7 +2045,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockDb->expects( $this->never() )
                        ->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -2130,7 +2126,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -2172,7 +2168,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                $mockCache->expects( $this->never() )->method( 'get' );
                $mockCache->expects( $this->never() )->method( 'delete' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );
@@ -2224,7 +2220,7 @@ class WatchedItemStoreUnitTest extends PHPUnit_Framework_TestCase {
                        ->method( 'delete' )
                        ->with( '0:SomeDbKey:1' );
 
-               $store = new WatchedItemStore(
+               $store = $this->newWatchedItemStore(
                        $this->getMockLoadBalancer( $mockDb ),
                        $mockCache
                );